﻿@model IEnumerable<NCLCustomerManagement.UI.Models.ProductCategory.ProductModel>
@{
    Layout = "";
    ViewBag.Title = "Danh sách sản phẩm";
    var currentUser = Session[NCLCustomerManagement.Common.Constant.Constant.CURRENT_USER]
                       as NCLCustomerManagement.UI.Models.User.AuthenticatedUser;
    var username = currentUser.Username;
    var isAdmin = currentUser.IsAdmin;                       
}



<div id="customer-list" class="area">
    <div class="btn-grp" style="margin-bott-om: 10px;">
        <div class="btn-toolbar">
            @using (Html.BeginForm())
            {
                <div class="row">
                    <div class="col-xs-3">
                        @*<select id="drRegion" class="form-control input-sm">
                        <option value="-1">Cả 3 miền</option>
                        <option value="0">Miền Bắc</option>
                        <option value="1">Miền Trung</option>
                        <option value="2">Miền Nam</option>
                    </select>*@
                        @Html.DropDownList("Category", ViewBag.CategorySelectList as SelectList, "Tất cả", new { @class = "form-control input-sm" })
                    </div>
                    <div class="col-xs-3">
                        <input id="ProductName" name="ProductName" value="@ViewBag.SearchProductName" type="search" class="form-control input-sm" placeholder="Gõ tên sản phẩm">
                    </div>
                    <div class="col-xs-3">

                        <input type="submit" id="btnSearch" class="btn btn-default" value="Tìm" />
                    </div>
                    <div class="col-xs-3" style="text-align: right;">
                        @if (isAdmin)
                        {
                            <a id="btnNew" class="btn btn-primary" href="/Product/New"><span class="glyphicon glyphicon-plus" title="Thêm khách hàng mới"></span></a>
                   
                        }


                    </div>
                </div>
            }
        </div>

    </div>
    @*<table id="list"></table>
    <div id="listPager" class="scroll" style="text-align: center;"></div>
    <div id="listPsetcols" class="scroll" style="text-align: center;"></div>*@
</div>
<ul id="productList">
    @foreach (var item in Model)
    {
        <li style="position: relative;">
            <div class="row">
                <div class="col-xs-3">
                    <input type="radio" class="product-select"  name="radSelect" value="@item.Id"/>
                    <input type="hidden"  value="@item.ProductName" class="product-name"/>
                    <input type="hidden"  value="@item.PrimaryUnit" class="product-unit"/>
                    <input type="hidden"  value="@string.Format("{0:#0.00}", item.CurrentSaleUnitPrice)" class="product-unit-price"/>
                    <img class="product-img" src=" @string.Format("{0}/{1}", @Url.Content("~/Upload/ProductImages"), @item.ImageUrl)" 
                        width="220px" height="220px;" />
                </div>
                <div class="col-xs-9" style="padding-le-ft: 20px;">
                    <a href="/Product/Edit/@item.Id">
                        <span style="color: #428bca; font-weight: bold;">@item.ProductName </span>
                    </a>
                    <div style="padding: 5px 0px 5px 0px; font-weight: bold;">@item.Description</div>

                    <div>Thuộc nhóm: @item.ProductCategoryName</div>
                    <div>Xuất xứ: @item.Madein</div>
                    <div>Giá bán: @string.Format("{0:#,##0} VND", item.CurrentSaleUnitPrice)</div>
                    <div>Đơn vị: @string.Format("{0} ({1}{2})", @item.PrimaryUnit, item.QuantityPerUnit, item.SecondaryUnit) </div>
                    <div>Tình trạng: @(item.Available ? "Còn hàng" : "Hết hàng")</div>
                    <div>
                        Liều dùng: @string.Format("{0}{1}/ngày, thời gian dùng dự tính: {2}",
                    item.UsedPerDay, item.SecondaryUnit,
                    item.TotalUseTimeString)
                    </div>

                    <div style="position: absolute; right: 15px; bottom: -55px;">
                        <div class="btn-group" style="float: right;">
                            <a id="btnEdit" class="btn btn-primary" href="/Product/Edit/@item.Id"><span class="glyphicon glyphicon-edit" title="Sửa"></span></a>
                            <a id="btnDel" class="btn btn-danger" href="/Product/Delete/@item.Id"><span class="glyphicon glyphicon-remove" title="Xóa"></span></a>


                        </div>
                    </div>

                </div>
            </div>
        </li>
    }
</ul>

